<?php
namespace app\common\model;

use think\Model;

class Archive extends Model
{
    public function arctype()
    {
        return $this->hasOne('Arctype', 'id', 'typeid');
    }
    public function member()
    {
        return $this->hasOne('Member', 'id', 'mid');
    }
    
    public function setFlagAttr($value, $data)
    {
        if (!empty($data['litpic'])){
            array_push($value, 'p');
        }else{
            $value = unset_array('p', $value);
        }
        return $value = implode(',', array_filter($value));
    }
    
    public function getFlagTextAttr($value, $data)
    {
        $arr = config('selectlist.flag')['data'];
        $flag = array_reverse(explode(',', $data['flag']));
        $res = '';
        foreach ($flag as $v){
            if (isset($arr[$v])){
                $res .= '<span class="label label-info">'.$arr[$v].'</span> ';
            }
        }
        return $res;
    }
}